<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="工号" prop="registerId">
        <el-input
          v-model="queryParams.registerId"
          placeholder="请输入DRI人员工号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="专案名称" prop="projectName">
        <el-select v-model="queryParams.projectName" filterable allow-create placeholder="请选择或输入专案名称"
                   clearable :style="{width: '88%'}" class="spangutter">
          <el-option v-for="(item, index) in projectNameOptions" :key="index" :label="item.label"
                     :value="item.value" :disabled="item.disabled"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="登记日期">
        <el-date-picker
          v-model="daterangeRegisterDate"
          size="small"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>

      <el-form-item label="状态" prop="currentState">
        <el-select v-model="queryParams.currentState" placeholder="请选择状态" clearable size="small">
          <el-option
            v-for="dict in dict.type.sys_completion_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="medium" @click="handleQuery">查询</el-button>

      </el-form-item>
    </el-form>

    <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>


    <el-table v-loading="loading" :data="informationList" @selection-change="handleSelectionChange">
      <el-table-column label="序号" align="center" prop="pId" width="80px" sortable />
      <el-table-column label="登记日期" align="center" prop="registerDate" width="120" sortable >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.registerDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="登记人" align="center" prop="registerPerson"/>
      <el-table-column label="厂区" align="center" prop="factoryName"/>
      <el-table-column label="专案名称" align="center" prop="projectName"/>
      <el-table-column label="专案等级" align="center" prop="projectLevel"/>
      <el-table-column label="楼栋" align="center" prop="floorNo"/>
      <el-table-column label="Room" align="center" prop="roomName"/>
      <el-table-column label="楼层" align="center" prop="locationFloor"/>
      <el-table-column label="DRI名称" align="center" prop="driName"/>
      <el-table-column label="DRI联系方式" align="center" prop="driPhone"/>
      <el-table-column label="安保负责人" align="center" prop="securityName"/>

      <el-table-column label="状态" align="center" prop="currentState">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_event_status" :value="scope.row.currentState"/>
        </template>
      </el-table-column>
      <el-table-column label="改善进度" align="center" prop="currentSchedule" />

      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['info:infordection:edit']"
          >编辑
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改专案稽核事项对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="850px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <el-divider content-position="center">专案相关信息</el-divider>
        <br/>
        <el-row type="flex" justify="start" align="top">
          <el-col :span="12">
            <el-form-item label="厂区" prop="factoryName">
              <el-select v-model="form.factoryName" filterable allow-create placeholder="请选择或输入厂区"
                         clearable :style="{width: '88%'}" class="spangutter">
                <el-option v-for="(item, index) in factoryNameOptions" :key="index" :label="item.label"
                           :value="item.value" :disabled="item.disabled"></el-option>
              </el-select>

            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="专案等级" prop="projectLevel">
              <el-select v-model="form.projectLevel" filterable allow-create placeholder="请选择或输入专案等级"
                         clearable :style="{width: '88%'}" class="spangutter">
                <el-option v-for="(item, index) in projectLevelOptions" :key="index" :label="item.label"
                           :value="item.value" :disabled="item.disabled"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row type="flex" justify="start" align="top">
          <el-col :span="12">
            <el-form-item label="专案代码" prop="projectName">
              <el-select v-model="form.projectName" filterable allow-create placeholder="请选择或输入专案名称"
                         clearable :style="{width: '88%'}" class="spangutter">
                <el-option v-for="(item, index) in projectNameOptions" :key="index" :label="item.label"
                           :value="item.value" :disabled="item.disabled"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="楼栋编号" prop="floorNo">
              <el-select v-model="form.floorNo" filterable allow-create placeholder="请选择或输入楼栋编号"
                         clearable :style="{width: '88%'}" class="spangutter">
                <el-option v-for="(item, index) in floorNoOptions" :key="index" :label="item.label"
                           :value="item.value" :disabled="item.disabled"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row type="flex" justify="start" align="top">
          <el-col :span="12">
            <el-form-item label="Room名" prop="roomName">
              <el-select v-model="form.roomName" filterable allow-create placeholder="请选择或输入楼栋编号Room名称"
                         clearable :style="{width: '88%'}" class="spangutter">
                <el-option v-for="(item, index) in roomNameOptions" :key="index" :label="item.label"
                           :value="item.value" :disabled="item.disabled"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="所在楼层" prop="locationFloor">
              <el-select v-model="form.locationFloor" filterable allow-create placeholder="请选择或输入所在楼层"
                         clearable :style="{width: '88%'}" class="spangutter">
                <el-option v-for="(item, index) in locationFloorOptions" :key="index" :label="item.label"
                           :value="item.value" :disabled="item.disabled"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row type="flex" justify="start" align="top">
          <el-col :span="12">
            <el-form-item label="DRI工号" prop="driId">
              <el-select
                v-model="form.driId"
                :style="{width: '88%'}"
                @change="drichange"
                filterable
                remote
                reserve-keyword
                placeholder="请输入或获取工号"
                :remote-method="remoteMethodId"
                :loading="loading">
                <el-option
                  v-for="item in options4"
                  :key="item.empId"
                  :label="item.empId"
                  :value="item.empId">
                  <span style="float: left">{{item.empId}}</span>
                  <span style="float: right">{{item.empName}}</span>
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="DRI名称" prop="driName">
              <el-select
                v-model="form.driName"
                :style="{width: '88%'}"
                @change="drinchange"
                filterable
                remote
                reserve-keyword
                placeholder="请输入或获取姓名"
                :remote-method="remoteMethodName"
                :loading="loading">
                <el-option
                  v-for="item in options4"
                  :key="item.empId"
                  :label="item.empName"
                  :value="item.empName">
                  <span style="float: left">{{item.empId}}</span>
                  <span style="float: right">{{item.empName}}</span>
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row type="flex" justify="start" align="top">
          <el-col :span="12">
            <el-form-item label="安保负责人工号" prop="securityId">
              <el-select
                v-model="form.securityId"
                :style="{width: '88%'}"
                @change="asgchange"
                filterable
                remote
                reserve-keyword
                placeholder="请输入或获取工号"
                :remote-method="remoteMethodIds"
                :loading="loading">
                <el-option
                  v-for="item in options5"
                  :key="item.empId"
                  :label="item.empId"
                  :value="item.empId">
                  <span style="float: left">{{item.empId}}</span>
                  <span style="float: right">{{item.empName}}</span>
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="安保负责人" prop="securityName">
              <el-select
                v-model="form.securityName"
                :style="{width: '88%'}"
                @change="asnchange"
                filterable
                remote
                reserve-keyword
                placeholder="请输入或获取姓名"
                :remote-method="remoteMethodNames"
                :loading="loading">
                <el-option
                  v-for="item in options5"
                  :key="item.empId"
                  :label="item.empName"
                  :value="item.empName">
                  <span style="float: left">{{item.empId}}</span>
                  <span style="float: right">{{item.empName}}</span>
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="DRI联系方式" prop="driPhone">
              <el-input v-model="form.driPhone" :style="{width: '88%'}" placeholder="请输入DRI联系方式" class="spangutter"/>
            </el-form-item>
          </el-col>
        </el-row>

        <el-divider content-position="center">改善事项</el-divider>

      </el-form>
      <el-table  :data="projectImproveMatterList" :row-class-name="rowProjectImproveMatterIndex"
                 @selection-change="handleProjectImproveMatterSelectionChange" ref="projectImproveMatter" >
        <el-table-column label="标题" :show-overflow-tooltip="true" align="center" prop="theme" />
        <el-table-column label="详细" :show-overflow-tooltip="true" align="center" prop="description" />
        <el-table-column label="责任人工号" align="center" prop="driId"  />
        <el-table-column label="责任人名称" align="center" prop="driName" />
        <el-table-column label="预计完成时间" align="center" prop="estimatedCompletionTime"  />

        <el-table-column label="状态" align="center" prop="improveState">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.sys_completion_status" :value="scope.row.improveState"/>
          </template>
        </el-table-column>

        <el-table-column label="修改"  align="center"  class-name="small-padding fixed-width" width="70">
          <template slot-scope="scope"  >
            <el-button
              type="primary"
              size="small"
              @click="delistchange(scope.row)"
            >修 改
            </el-button>
          </template>
        </el-table-column>
      </el-table>

      <div slot="footer" class="dialog-footer">
        <el-button type="primary"  @click="submitForm">保 存</el-button>
        <el-button @click="cancel">关闭窗口</el-button>
      </div>
    </el-dialog>
    <el-dialog :title="dialogtitle" :visible.sync="dialogTableVisible" width="600px" center>
      <el-form ref="titleform" :model="titleform" :rules="rules">
        <el-row>
          <el-col :span="24">
            <el-form-item label="标题" prop="theme">
              <el-input v-model="titleform.theme"  placeholder="请输入标题" clearable :style="{width: '87%'}">
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="详细" prop="description">
              <el-input v-model="titleform.description" type="textarea" placeholder="请输入详细"
                        :autosize="{minRows: 2, maxRows: 4}" :style="{width: '87%'}"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row type="flex" justify="start" align="top">
          <el-col :span="12">
            <el-form-item label="责任人工号" prop="driId">
              <el-select
                v-model="titleform.driId"
                :style="{width: '88%'}"
                @change="driIdchange"
                filterable
                remote
                reserve-keyword
                placeholder="请输入或获取工号"
                :remote-method="remoteMethoddirIds"
                :loading="loading">
                <el-option
                  v-for="item in options6"
                  :key="item.empId"
                  :label="item.empId"
                  :value="item.empId">
                  <span style="float: left">{{item.empId}}</span>
                  <span style="float: right">{{item.empName}}</span>
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="责任人名称" prop="driName">
              <el-select
                v-model="titleform.driName"
                :style="{width: '88%'}"
                @change="driNamechange"
                filterable
                remote
                reserve-keyword
                placeholder="请输入或获取姓名"
                :remote-method="remoteMethoddriNames"
                :loading="loading">
                <el-option
                  v-for="item in options6"
                  :key="item.empId"
                  :label="item.empName"
                  :value="item.empName">
                  <span style="float: left">{{item.empId}}</span>
                  <span style="float: right">{{item.empName}}</span>
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="预计完成时间" prop="estimatedCompletionTime">
              <el-date-picker
                v-model="titleform.estimatedCompletionTime"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择日期"
                :style="{width: '88%'}">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <el-button type="primary" @click="definiteBtn()">确定</el-button>
    </el-dialog>
  </div>
</template>


<script>
import {
  listInformation,
  getInformation,
  delInformation,
  addInformation,
  updateInformation,
  exportInformation,
  getInformationValue,
  getuserIdValue
} from "@/api/mine/projectAuditMatter";
import { listEmpByKey } from "@/api/mine/securityAuditMatter";

export default {
  name: "projectAuditMatter",
  dicts: ['sys_completion_status','sys_event_status'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 子表选中数据
      checkedProjectImproveMatter: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 专案稽核事项表格数据
      informationList: [],
      // 专案稽核事项详细记录表格数据
      projectImproveMatterList: [],
      // 弹出层标题
      title: "",
      dialogtitle: "输入详情信息",
      // 是否显示弹出层
      open: false,
      dialogTableVisible: false,
      // 完成时间时间范围
      daterangeRegisterDate: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        registerDate: null,
        registerId: null,
        projectName: "",
        currentState: [],
        contentArea: null,
      },
      titleform: {
        itemTitle: "",
        itemDetail: "",
        personalID: "",
        personal: "",
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        registerDate: [
          {required: true, message: "登记日期不能为空", trigger: "blur"}
        ],
        registerId: [
          {required: true, message: "登记人员工号不能为空", trigger: "blur"}
        ],
        registerPerson: [
          {required: true, message: "登记人员姓名不能为空", trigger: "blur"}
        ],
        factoryName: [
          {required: true, message: "厂区不能为空", trigger: "blur"}
        ],
        projectName: [
          {required: true, message: "专案名称不能为空", trigger: "change"}
        ],
        projectLevel: [
          {required: true, message: "专案等级 0：低、1：中:2：高;不能为空", trigger: "blur"}
        ],
        floorNo: [
          {required: true, message: "楼栋编号不能为空", trigger: "blur"}
        ],
        roomName: [
          {required: true, message: "Room名称不能为空", trigger: "blur"}
        ],
        locationFloor: [
          {required: true, message: "所在楼层不能为空", trigger: "blur"}
        ],
        driId: [
          {required: true, message: "DRI工号不能为空", trigger: "blur"}
        ],
        driName: [
          {required: true, message: "DRI名称不能为空", trigger: "blur"}
        ],
        driPhone: [
          {required: true, message: "DRI联系方式不能为空", trigger: "blur"}
        ],
        securityId: [
          {required: true, message: "安保负责人ID不能为空", trigger: "blur"}
        ],
        securityName: [
          {required: true, message: "安保负责人姓名不能为空", trigger: "blur"}
        ],
        theme: [
          {required: true, message: "标题不能为空", trigger: "blur"}
        ],
        description: [
          {required: true, message: "详情不能为空", trigger: "blur"}
        ],
        estimatedCompletionTime: [
          {required: true, message: "预计完成时间不能为空", trigger: "blur"}
        ]
        // currentState: [
        //   {required: true, message: "状态  0：未完成   1：已完成不能为空", trigger: "blur"}
        // ]
      },

      factoryNameOptions: [],
      projectLevelOptions: [],
      projectNameOptions: [],
      floorNoOptions: [],
      roomNameOptions: [],
      locationFloorOptions: [],
      options4: [],
      options5: [],
      options6: []

    };
  },
  created() {
    this.getList();
    this.getprojectNameList();
  },
  methods: {
    /** 查询专案稽核事项列表 */
    getList() {
      this.loading = true;
      this.queryParams.params = {};
      if (null != this.daterangeRegisterDate && '' != this.daterangeRegisterDate) {
        this.queryParams.params["beginRegisterDate"] = this.daterangeRegisterDate[0];
        this.queryParams.params["endRegisterDate"] = this.daterangeRegisterDate[1];
      }
      //
      listInformation(this.queryParams).then(response => {
        this.informationList = response.rows;
        console.log(response)
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        pId: null,
        registerDate: null,
        registerId: null,
        registerPerson: null,
        factoryName: null,
        projectName: null,
        projectLevel: null,
        floorNo: null,
        roomName: null,
        locationFloor: null,
        driId: null,
        driName: null,
        driPhone: null,
        securityId: null,
        securityName: null,
        currentState: null,
      };
      this.projectImproveMatterList = [];
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.daterangeRegisterDate = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.pId)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    // 查询厂区下拉框
    getfactoryList() {
      this.loading = true;
      let str = "factoryName"
      getInformationValue(str).then(response => {
        this.factoryNameOptions = response.data;
        this.loading = false;
      });
    },
    /** 查询专案等级下拉框 */
    getprojectLevelList() {
      this.loading = true;
      let str = "projectLevel"
      getInformationValue(str).then(response => {
        this.projectLevelOptions = response.data;
        this.loading = false;
      });
    },
    /** 查询专案名称下拉框 */
    getprojectNameList() {
      this.loading = true;
      let str = "projectName"
      getInformationValue(str).then(response => {
        this.projectNameOptions = response.data;
        this.loading = false;
      });
    },
    /** 查询楼栋编号下拉框 */
    getfloorNoList() {
      this.loading = true;
      let str = "floorNo"
      getInformationValue(str).then(response => {
        this.floorNoOptions = response.data;
        this.loading = false;
      });
    },
    //查询Room名称下拉框
    getroomNameList() {
      this.loading = true;
      let str = "roomName"
      getInformationValue(str).then(response => {
        this.roomNameOptions = response.data;
        this.loading = false;
      });
    },
    //查询所在楼层下拉框
    getlocationFloorList() {
      this.loading = true;
      let str = "locationFloor"
      getInformationValue(str).then(response => {
        this.locationFloorOptions = response.data;
        this.loading = false;
      });
    },
    /** 查询输入工号调取方法展示数据 */
    searchFile() {
      let userIdData = document.getElementById("userIdInput").value;
      getuserIdValue(userIdData).then(response => {
        let empName = response.data[0].empName;
        document.getElementById("DRIname").value = empName;
        this.loading = false;
      });

    },

    driIdchange(val){
      for(var i = 0;i<this.options6.length;i++){
        if(this.options6[i].empId == val){
          this.titleform.driName = this.options6[i].empName;
        }
      }
    },
    driNamechange(val){
      for(var i = 0;i<this.options6.length;i++){
        if(this.options6[i].empName == val){
          this.titleform.driId = this.options6[i].empId;
        }
      }
    },
    asgchange(val){
      for(var i = 0;i<this.options5.length;i++){
        if(this.options5[i].empId == val){
          this.form.securityName = this.options5[i].empName ;
        }
      }
    },
    asnchange(val){
      for(var i = 0;i<this.options5.length;i++){
        if(this.options5[i].empName == val){
          this.form.securityId = this.options5[i].empId;
        }
      }
    },

    drichange(val){
      for(var i = 0;i<this.options4.length;i++){
        if(this.options4[i].empId == val){
          this.form.driName = this.options4[i].empName;
        }
      }
    },
    drinchange(val){
      for(var i = 0;i<this.options4.length;i++){
        if(this.options4[i].empName == val){
          this.form.driId = this.options4[i].empId;
        }
      }
    },
    //DRI人员id获取姓名
    remoteMethodId(query) {
      if(query.length >= 7){
        listEmpByKey(query).then(response => {
          this.options4 = response.data;
        })
      }
    },
    remoteMethodIds(query) {
      if(query.length >= 7){
        listEmpByKey(query).then(response => {
          this.options5 = response.data;
        })
      }
    },
    remoteMethoddirIds(query) {
      if(query.length >= 7){
        listEmpByKey(query).then(response => {
          this.options6 = response.data;
        })
      }
    },
    remoteMethodName(query) {
      if(query.length >= 2&&query.length <= 4){
        listEmpByKey(query).then(response => {
          this.options4 = response.data;
        })
      }
    },
    remoteMethodNames(query) {
      if(query.length >= 2&&query.length <= 4) {
        listEmpByKey(query).then(response => {
          this.options5 = response.data;
        })
      }
    },
    remoteMethoddriNames(query) {
      if(query.length >= 2&&query.length <= 4){
        listEmpByKey(query).then(response => {
          this.options6 = response.data;
        })
      }
    },
    /** 修改事项按钮 */
    delistchange(row) {
      this.dialogTableVisible = true;
      if(this.$refs.titleform){
        this.$refs.titleform.clearValidate();
      }
      this.titleform = row;
      for(var i = 0;i<this.projectImproveMatterList.length,i++;){
        if(this.projectImproveMatterList[i].index == row.index){
          this.projectImproveMatterList[i].splice(i,1,1,this.titleform)
        }
      }
    },

    // 点击编辑标题 窗体
    editTitle() {
      let edituserTitleData = document.getElementById("edituserTitle").value;
      console.log('测试输入详细', edituserTitleData)
      this.dialogTableVisible = true;
    },

    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.getprojectLevelList();
      this.getfactoryList();
      this.getprojectNameList();
      this.getfloorNoList();
      this.getroomNameList();
      this.getlocationFloorList();
      this.options4 = []
      // this.editTitle();
      this.open = true;
      this.title = "添加专案稽核事项";
    },

    // 弹出窗体确定按钮
    definiteBtn() {
      this.$refs["titleform"].validate((valid) =>{
        if(valid){
          for(var i = 0;i<this.projectImproveMatterList.length,i++;){
            if(this.projectImproveMatterList[i].index == this.titleform.index){
              this.projectImproveMatterList[i].splice(i,1,1,this.titleform)
            }
          }
          this.$modal.msgSuccess("修改成功");
        }else {
          return false;
        }
        this.dialogTableVisible = false;
      })
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      this.getprojectLevelList();
      this.getfactoryList();
      this.getprojectNameList();
      this.getfloorNoList();
      this.getroomNameList();
      this.getlocationFloorList()
      this.options4 = []

      const pId = row.pId || this.ids
      getInformation(pId).then(response => {
        this.form = response.data;
        this.projectImproveMatterList = response.data.projectImproveMatterList;
        this.open = true;
        this.title = "修改专案稽核事项";
      });
    },

    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.pId != null) {
            updateInformation(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const pIds = row.pId || this.ids;
      this.$modal.confirm('是否确认删除专案稽核事项编号为"' + pIds + '"的数据项？').then(function () {
        return delInformation(pIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {
      });
    },
    /** 专案稽核事项详细记录序号 */
    rowProjectImproveMatterIndex({row, rowIndex}) {0
      row.index = rowIndex + 1;
    },
    /** 专案稽核事项详细记录删除按钮操作 */
    handleDeleteProjectImproveMatter() {
      if (this.checkedProjectImproveMatter.length == 0) {
        this.$modal.msgError("请先选择要删除的专案稽核事项详细记录数据");
      } else {
        const projectImproveMatterList = this.projectImproveMatterList;
        const checkedProjectImproveMatter = this.checkedProjectImproveMatter;
        this.projectImproveMatterList = projectImproveMatterList.filter(function (item) {
          return checkedProjectImproveMatter.indexOf(item.index) == -1
        });
        this.$modal.msgSuccess("删除成功");
      }
    },

    /** 复选框选中数据 */
    handleProjectImproveMatterSelectionChange(selection) {
      this.checkedProjectImproveMatter = selection.map(item => item.index)
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$modal.confirm('是否确认导出所有专案稽核事项数据项？').then(() => {
        this.exportLoading = true;
        return exportInformation(queryParams);
      }).then(response => {
        this.$download.name(response.msg);
        this.exportLoading = false;
      }).catch(() => {
      });
    }
  }
};
</script>
<style>
.spangutter {
  width: 220px;
}

</style>
